public class Main1 {
    //第二种方法  提取各位数字
    public static void main(String[] args) {
        int cnt = 0;
        for (int i = 1; ; i++) {
            if (check(i,2)==0&&check(i,8)==0&&check(i,10)==0&&check(i,16)==0){
                cnt++;
                if (cnt==2023){
                    System.out.println(i);
                    break;
                }
            }
        }

    }

    public static int check(int n, int p) {
        String s = "";
        if (p == 2) {
            s = Integer.toBinaryString(n);
        } else if (p == 8) {
            s = Integer.toOctalString(n);
        } else if (p == 10) {
            s = n + "";
        } else if (p == 16) {
            s = Integer.toHexString(n);
        }
        int ans = sumlen(s);
        return n % ans;
    }

    public static int sumlen(String s) {
        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            char t = s.charAt(i);
            if (t >= '0' && t <= '9') {
                ans += t - '0';
            }
            else{
                ans += t - 'a' + 10;}

        }
        return ans;
    }
}